package model.load
{
	import core.Model;
	
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.net.URLRequestMethod;
	
	import model.system.TraceManager;
	
	public class AbsLoadMessage extends EventDispatcher implements ILoadMessage
	{
		private var _url:String;
		protected var _dataFormat:String;
		protected static var _model:Model = Model.getInstance();
		private var _id:int;
		private var _isTimeOutReload:Boolean = true;
		private var _method:String;
		private var _urlvariable:*;
		private var _timeout:int = 10000;
		private var _contentType:String;
		protected var _isDisplayObject:Boolean;
		protected var _isCompress:Boolean;
		protected var _isImmediate:Boolean;//是否立即处理
		
		public function AbsLoadMessage()
		{
			_method = URLRequestMethod.GET;
		}
		
		public function set isImmediate(v:Boolean):void
		{
			_isImmediate = v;
		}
		
		public function get isImmediate():Boolean
		{
			return _isImmediate;	
		}
		
		public function get isCompress():Boolean
		{
			return _isCompress;
		}
		
		public function set isCompress(v:Boolean):void
		{
			_isCompress = v;
		}
		
		public function get isDisplayObject():Boolean
		{
			return _isDisplayObject;
		}
		
		public function get contentType():String
		{
			return _contentType;
		}

		public function set contentType(v:String):void
		{
			_contentType = v;
		}

		public function get timeout():int
		{
			return _timeout;
		}

		public function set timeout(v:int):void
		{
			_timeout = v * 1000;
		}

		public function get urlvariable():*
		{
			return _urlvariable;
		}

		public function set urlvariable(v:*):void
		{
			_urlvariable = v;
		}

		public function get method():String
		{
			return _method;
		}

		public function set method(v:String):void
		{
			_method = v;
		}

		public function get isTimeOutReload():Boolean
		{
			return _isTimeOutReload;
		}

		public function set isTimeOutReload(v:Boolean):void
		{
			_isTimeOutReload = v;
		}

		public function get id():int
		{
			return _id;
		}

		public function set id(v:int):void
		{
			_id = v;
		}

		public function get url():String
		{
			return _url;
		}
		
		public function set url(v:String):void
		{
			_url = v;
		}
		
		public function get dataFormat():String
		{
			return _dataFormat;
		}
		
		public function send():void
		{
			if (_url == null)
			{
				throw Error("loadMessage Error : _url null");
			}
			
			_model.loaderPoolModel.addLoadMessage(this);
		}
		
		public function back(...args):void
		{
			
		}
		
		public function set percent(v:Number):void
		{
			
		}
		
		public function cancel():void
		{
			TraceManager.getInstance().out("Load Cancel Msg:",url);
			dispatchEvent(new Event(Event.CANCEL));
			
		}
		
		public function onTimeOut():void
		{
		
		}
	}
}